#!/bin/bash

# 定义输出文件的名称
output_file="pkID_result.txt"
pkid_path="~/personalScripts/APPScripts/apkscan-pkid-v2.0.py"
# 检查keytool命令是否存在
if ! command -v python &> /dev/null
then
    echo "python could not be found, please ensure it's installed and in your PATH."
    exit 1
fi

# 清空输出文件，如果它已经存在
> "$output_file"

# 遍历当前目录下的所有apk文件
for apk_file in *.apk; do
    if [ -f "$apk_file" ]; then
        # 使用keytool处理apk文件，并将输出追加到output.txt
        python $pkid_path "$apk_file" >> "$output_file"
        echo "Processed $apk_file" >> "$output_file"
        echo "Processed $apk_file to $output_file"
    else
        echo "No .apk files found in the current directory."
        exit 1
    fi
done

echo "All .apk files have been processed. Output saved to $output_file."
